FROM  golang:1.17.6-alpine

# 工作目录
WORKDIR /go/src/app
COPY . .

# 处理系统依赖
# 使用阿里源&&设置东八区，北京时间 (安装gcc工具)
ENV TZ=Asia/Shanghai
RUN echo -e http://mirrors.aliyun.com/alpine/v3.10/main/ > /etc/apk/repositories \
    && apk update \
    && apk add --no-cache tzdata gcc g++ libffi-dev musl-dev openssl-dev make linux-headers libc-dev libc6-compat binutils \
    && ln -sf /usr/share/zoneinfo/$TZ /etc/localtime \
    && echo $TZ > /etc/timezone

# 处理项目依赖
RUN ./go-env.sh \
#    && go mod tidy \   # 项目自身管理依赖
    && go build -o server ./server.go \
    && go build -o client ./client.go \
    && chmod +x server client

ENTRYPOINT ["./server"]
